package com.sun.controller;

import com.sun.entity.R;
import com.sun.service.ISquadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author SunRui
 * @since 2024-12-11
 */
@RestController
@RequestMapping("/squad")
@Tag(name = "小组前端控制器",description = "小组接口")
@CrossOrigin
public class SquadController {

    @Autowired
    ISquadService squadService;

    // 查询小组列表
    @GetMapping
    @Operation(summary = "查询小组列表",description = "查询列表接口")
    @ApiResponses(value = {@ApiResponse(responseCode = "200",description = "成功"),
            @ApiResponse(responseCode = "404",description = "失败")})
    public R selectSquadList(){
        return R.success(squadService.selectQuadList());
    }

    // 根据小组名称查询列表
    @GetMapping("/name")
    @Operation(summary = "根据小组名查询小组列表",description = "查询列表接口")
    @ApiResponses(value = {@ApiResponse(responseCode = "200",description = "成功"),
            @ApiResponse(responseCode = "404",description = "失败")})
    public R selectSquadListByName(@Parameter(name = "小组名称")String name){
        return R.success(squadService.selectQuadListByName(name));
    }

}
